package com.ironmaking.Vo.results;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @ClassName ActionResult
 * @Description http返回对象
 */
@Getter
@Setter
@ApiModel(description="基础返回类")
public class ActionResult {

    @ApiModelProperty(example="true")
    private boolean isSuccess;

    @ApiModelProperty(example="200")
    private int code;

    @ApiModelProperty(example="成功")
    private String msg;

    @ApiModelProperty(example= "null")
    private Object Data;

    /**
     *
     * @param isSuccess
     * @param code
     * @param msg
     * @param data
     */
    private ActionResult(boolean isSuccess, int code, String msg, Object data){
        this.isSuccess = isSuccess;
        this.code = code;
        this.msg = msg;
        this.Data = data;
    }

    /**
     *
     * @param data
     * @return PostResult
     */
    public static ActionResult success(Object data){
        return new ActionResult(true,200,"success",data);
    }

    /**
     *
     * @param code
     * @param msg
     * @return PostResult
     */
    public static ActionResult fail(int code, String msg){
        return new ActionResult(false,code,msg,null);
    }
}
